package com.uwo.house.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;

/**
 * Created by dell on 2017/12/9.
 */
public class RandChars {
    private static SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");

    public RandChars() {
    }

    public static String getRandomString(int length) {
        String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";
        Random random = new Random();
        StringBuffer sb = new StringBuffer();

        for (int i = 0; i < length; ++i) {
            int number = random.nextInt(base.length());
            sb.append(base.charAt(number));
        }

        return sb.toString();
    }

    public static String timeStart() {
        return df.format(new Date());
    }

    public static String timeExpire() {
        Calendar now = Calendar.getInstance();
        now.add(12, 30);
        return df.format(Long.valueOf(now.getTimeInMillis()));
    }

    public static void main(String[] args) {
        System.out.println("开始时间是：" + timeStart());
        System.out.println("开始时间是：" + timeExpire());
    }
}
